public class code2 {
    public int numDecodings(String ss) {
        int n = ss.length();
        char[] s = ss.toCharArray();
        int[] dp = new int[n+1];
        //初始化
        dp[0] = 1;//保证后续填表是正确的
        if (s[1-1]!='0') dp[1]=1;

        for (int i = 2; i <= n; i++) {
            if (s[i-1]!='0') dp[i]+=dp[i-1];

            int t = 10*(s[i-2]-'0')+(s[i-1]-'0');
            if (t>=10&&t<=26) dp[i]+=dp[i-2];

        }
        return dp[n];
    }
}
